package com.apps.ftapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.apps.ftapp.R;
import com.apps.ftapp.bean.TestpapersBean;
import com.apps.ftapp.model.LessonModel;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;

import java.util.List;

public class TestAdapter extends ArrayAdapter<TestpapersBean> {


    private int resource;
    private Context context;

    public TestAdapter(Context context, int resource, List<TestpapersBean> objects) {

        super(context, resource, objects);
        this.resource = resource;
        this.context = context;
        //显示图片的配置  

    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {


        TestpapersBean bean = getItem(position);
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(getContext()).inflate(resource, null, false);
            holder = new ViewHolder();

            holder.title = view.findViewById(R.id.test_title);
            holder.done = view.findViewById(R.id.test_btn);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.title.setText(bean.getName());
        if (bean.getAlready() == 1) {
            holder.done.setText("已做过");
        } else {
            holder.done.setText("未做过，马上开始做题");

        }


        return view;
    }


    private class ViewHolder {

        TextView title;
        TextView done;
    }


}
